package org.example.java8.localDate;

import java.time.LocalTime;
import java.time.temporal.ChronoUnit;

/**
 * java.time.LocalTime:
 * LocalTime只提供时间而不提供日期信息，它是不可变类且线程安全的。
 *
 * This class demonstrates JAVA 8 data and time API
 *
 * @author Siva Prasad Rao Janapati
 */
public class LocalTimeDemonstration {
    /**
     * @param args
     */
    public static void main(String[] args) {
        //Get local time
        LocalTime localTime = LocalTime.now();
        System.out.println(localTime);
        //Get the hour of the day
        System.out.println("The hour of the day:: " + localTime.getHour());
        //add 2 hours to the time.
        System.out.println(localTime.plus(2, ChronoUnit.HOURS));
        //add 6 minutes to the time.
        System.out.println(localTime.plusMinutes(6));
        //substract 2 hours from current time
        System.out.println(localTime.minus(2, ChronoUnit.HOURS));
    }
}